From: Shannon Zhao Date: Sat, 23 Jan 2016 08:00:20 +0000 (+0800) Subject: pl011: Refactor pl011 driver to dt and common initialization parts X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~1813 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=0f5f9d8933258f49371a4e85e7459726c593d4ac;p=xen.git pl011: Refactor pl011 driver to dt and common initialization parts Refactor pl011 driver to dt and common initialization parts. This will be useful later when acpi specific uart initialization function is introduced. Signed-off-by: Parth Dixit Signed-off-by: Shannon Zhao Acked-by: Stefano Stabellini --- diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c index 67e6df5b31..7e16294c7c 100644 --- a/xen/drivers/char/pl011.c +++ b/xen/drivers/char/pl011.c @@ -226,12 +226,42 @@ static struct uart_driver __read_mostly pl011_driver = { .vuart_info = pl011_vuart, }; +static int __init pl011_uart_init(int irq, u64 addr, u64 size) +{ + struct pl011 *uart; + + uart = &pl011_com; + uart->irq = irq; + uart->clock_hz = 0x16e3600; + uart->baud = BAUD_AUTO; + uart->data_bits = 8; + uart->parity = PARITY_NONE; + uart->stop_bits = 1; + + uart->regs = ioremap_nocache(addr, size); + if ( !uart->regs ) + { + printk("pl011: Unable to map the UART memory\n"); + return -ENOMEM; + } + + uart->vuart.base_addr = addr; + uart->vuart.size = size; + uart->vuart.data_off = DR; + uart->vuart.status_off = FR; + uart->vuart.status = 0; + + /* Register with generic serial driver. */ + serial_register_uart(SERHND_DTUART, &pl011_driver, uart); + + return 0; +} + /* TODO: Parse UART config from the command line */ -static int __init pl011_uart_init(struct dt_device_node *dev, - const void *data) +static int __init pl011_dt_uart_init(struct dt_device_node *dev, + const void *data) { const char *config = data; - struct pl011 *uart; int res; u64 addr, size; @@ -240,14 +270,6 @@ static int __init pl011_uart_init(struct dt_device_node *dev, printk("WARNING: UART configuration is not supported\n"); } - uart = &pl011_com; - - uart->clock_hz = 0x16e3600; - uart->baud = BAUD_AUTO; - uart->data_bits = 8; - uart->parity = PARITY_NONE; - uart->stop_bits = 1; - res = dt_device_get_address(dev, 0, &addr, &size); if ( res ) { @@ -262,24 +284,14 @@ static int __init pl011_uart_init(struct dt_device_node *dev, printk("pl011: Unable to retrieve the IRQ\n"); return -EINVAL; } - uart->irq = res; - uart->regs = ioremap_nocache(addr, size); - if ( !uart->regs ) + res = pl011_uart_init(res, addr, size); + if ( res < 0 ) { - printk("pl011: Unable to map the UART memory\n"); - return -ENOMEM; + printk("pl011: Unable to initialize\n"); + return res; } - uart->vuart.base_addr = addr; - uart->vuart.size = size; - uart->vuart.data_off = DR; - uart->vuart.status_off = FR; - uart->vuart.status = 0; - - /* Register with generic serial driver. */ - serial_register_uart(SERHND_DTUART, &pl011_driver, uart); - dt_device_set_used_by(dev, DOMID_XEN); return 0; @@ -293,7 +305,7 @@ static const struct dt_device_match pl011_dt_match[] __initconst = DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL) .dt_match = pl011_dt_match, - .init = pl011_uart_init, + .init = pl011_dt_uart_init, DT_DEVICE_END /*